package com.iflytek.day09;

public class TwoDimensionDemo3 {
    public static void main(String[] args) {

        // 一维数组
        int[] arr1_1 = {1, 2, 3};
        int[] arr1_2 = {4, 5, 6};
        int[] arr2_1 = {7, 8, 9};
        int[] arr2_2 = {10, 11, 12};
        int[] arr3_1 = {13, 14, 15};
        int[] arr3_2 = {16, 17, 18};

        // 二维数组
        int[][] arr1 = new int[][]{arr1_1, arr1_2};
        int[][] arr2 = new int[][]{arr2_1, arr2_2};
        int[][] arr3 = new int[][]{arr3_1, arr3_2};

        // 三维数组
        int[][][] array1 = new int[][][]{arr1, arr2, arr3};

        int[][][] array2 = {
                {{1, 2, 3}, {4, 5, 6}},
                {{7, 8, 9}, {10, 11, 12}},
                {{13, 14, 15}, {16, 17, 18}}
        };

        //三维数组遍历
        System.out.println("{");
        for (int i = 0; i < array1.length; i++) {
            System.out.println("  {");
            for (int j = 0; j < array1[i].length; j++) {
                System.out.print("    {");
                for (int k = 0; k < array1[i][j].length; k++) {
                    //j:表示一维数组中的每一个元素
                    System.out.print(array1[i][j][k]);
                    if (k != array1[i][j].length - 1) {
                        System.out.print(",");
                    }
                }
                if (j != array1[i].length - 1) {
                    System.out.println("},");
                } else {
                    System.out.println("}");
                }
            }
            if (i != array1.length - 1) {
                System.out.println("  },");
            } else {
                System.out.println("  }");
            }
        }
        System.out.println("}");
    }
}
